import { NextResponse } from "next/server";
import connect from "@/utils/mongodb";
import Post from "@/model/Post";

// 获取全部文章（不进行账户隔离）
export const GET = async () => {
  try {
    await connect();
    const posts = await Post.find(); // 不添加任何过滤条件，获取所有文章
    return NextResponse.json(posts);
  } catch (error) {
    console.error("获取全部文章失败:", error);
    return NextResponse.json(
      { message: "获取全部文章失败" },
      { status: 500 }
    );
  }
};